package com.michael.databindingdemo;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.widget.AppCompatTextView;
import androidx.databinding.BindingMethod;
import androidx.databinding.BindingMethods;

/**
 */
@BindingMethods(
        {
                @BindingMethod(
                        type = AppCompatTextView.class,
                        attribute = "toast",
                        method = "showToast")
        })
public class CustomTextView extends androidx.appcompat.widget.AppCompatTextView {
    public CustomTextView(Context context) {
        super(context);
    }

    public CustomTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public void showToast(String content){
        Toast.makeText(getContext(), "toast:"+content, Toast.LENGTH_SHORT).show();
    }
}